package sos.entrega2013.mr1.noviembre.bo.facturacion;


import java.io.IOException;
import java.util.Iterator;

import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapred.*;

import sos.entrega2013.mr1.noviembre.beans.CDR;

public class FacturacionReduce extends MapReduceBase 
	implements Reducer<Text, CDR, Text, Text> {
	private final Double CosteEstLlamada=10.0;
	@Override
	public void reduce(Text key, Iterator<CDR> values,
			OutputCollector<Text, Text> output, Reporter reporter)
			throws IOException {
		
		Double CosteTotal=0.0;
		while(values.hasNext()){
			CDR cdrLlamada=values.next();
			CosteTotal=this.CosteEstLlamada+cdrLlamada.getDuracion();
		}
		output.collect(key, new Text(String.valueOf(CosteTotal)));
	}

}
